package com.zrgk.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zrgk.bean.MarketBean;
import com.zrgk.dao.MarketDao;
import com.zrgk.util.PageUtil;

/**
 * DPS
 * @author Administrator
 *	销售计划 实现类
 */
@Service(value="marketService")
@Transactional(propagation = Propagation.REQUIRED)
public class MarketServiceImpl implements MarketService{

	@Autowired
	@Qualifier(value ="marketDao")
	private MarketDao marketDao;
	
	//查找全部
	public List<MarketBean> listMarket() {
		return marketDao.listMarket();
	}
	//添加
	public void insertMarket(MarketBean market) {
		marketDao.insertMarket(market);	
	}


	//修改
	public void updateMarket(MarketBean market) {
		marketDao.updateMarket(market);
	}
	//根据ID查找
	public MarketBean findById(int id) {
		return marketDao.findById(id);
	}
	public MarketDao getMarketDao() {
		return marketDao;
	}
	
	public void setMarketDao(MarketDao marketDao) {
		this.marketDao = marketDao;
	}
	public void findMarketByPage(PageUtil pageUtil) {
		Map<String, String> map = pageUtil.getSearchInfo();
		Page<Object> sPage = PageHelper.startPage(pageUtil.getNowPage(), pageUtil.getPageSize());
		pageUtil.setList(marketDao.listMarket());
		Long totalCount = sPage.getTotal();
		pageUtil.setTotalCount(totalCount.intValue());
		pageUtil.setTotalPage(sPage.getPageNum());
		
		
	}

	
	

}
